package com.note.app.dto.collaboration;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * WebSocket消息传输DTO
 */
@Data
@Schema(description = "协作消息")
public class CollaborationMessageDTO {
    
    @Schema(description = "消息类型: JOIN-加入, LEAVE-离开, OPERATION-操作, CURSOR-光标, STATE-状态")
    private String type;
    
    @Schema(description = "消息发送者ID")
    private Long senderId;
    
    @Schema(description = "会话ID")
    private Long sessionId;
    
    @Schema(description = "消息内容")
    private String content;
    
    /**
     * 创建加入消息
     */
    public static CollaborationMessageDTO joinMessage(Long userId, Long sessionId, String content) {
        CollaborationMessageDTO message = new CollaborationMessageDTO();
        message.setType("JOIN");
        message.setSenderId(userId);
        message.setSessionId(sessionId);
        message.setContent(content);
        return message;
    }
    
    /**
     * 创建离开消息
     */
    public static CollaborationMessageDTO leaveMessage(Long userId, Long sessionId) {
        CollaborationMessageDTO message = new CollaborationMessageDTO();
        message.setType("LEAVE");
        message.setSenderId(userId);
        message.setSessionId(sessionId);
        return message;
    }
    
    /**
     * 创建操作消息
     */
    public static CollaborationMessageDTO operationMessage(Long userId, Long sessionId, String content) {
        CollaborationMessageDTO message = new CollaborationMessageDTO();
        message.setType("OPERATION");
        message.setSenderId(userId);
        message.setSessionId(sessionId);
        message.setContent(content);
        return message;
    }
    
    /**
     * 创建光标消息
     */
    public static CollaborationMessageDTO cursorMessage(Long userId, Long sessionId, String position) {
        CollaborationMessageDTO message = new CollaborationMessageDTO();
        message.setType("CURSOR");
        message.setSenderId(userId);
        message.setSessionId(sessionId);
        message.setContent(position);
        return message;
    }
    
    /**
     * 创建状态消息
     */
    public static CollaborationMessageDTO stateMessage(Long userId, Long sessionId, String state) {
        CollaborationMessageDTO message = new CollaborationMessageDTO();
        message.setType("STATE");
        message.setSenderId(userId);
        message.setSessionId(sessionId);
        message.setContent(state);
        return message;
    }
}